/*
 * TGS - Transportadora de Gas del Sur
 * 
 * Proyecto MAITE II
 */
package com.hexacta.hrs.security;

import net.sf.acegisecurity.Authentication;
import net.sf.acegisecurity.UserDetails;
import net.sf.acegisecurity.providers.dao.PasswordDaoAuthenticationProvider;

/**
 * Clase: HrsPasswordDaoAuthenticationProvider.
 */
public class HrsPasswordDaoAuthenticationProvider extends PasswordDaoAuthenticationProvider {

    /**
     * @see net.sf.acegisecurity.providers.dao.PasswordDaoAuthenticationProvider#createSuccessAuthentication(java.lang.Object,
     *      net.sf.acegisecurity.Authentication,
     *      net.sf.acegisecurity.UserDetails)
     */
    @Override
    protected Authentication createSuccessAuthentication(final Object principal, final Authentication authentication,
            final UserDetails user) {
        HrsUser hrsUser = (HrsUser) user;
        HrsAuthentication auth = new HrsAuthenticationImpl(principal, authentication.getCredentials(), user
                .getAuthorities(), hrsUser.getEmailAddress(), hrsUser.getAccountPasswordStatus());
        return auth;
    }

}
